package snooker.scoreboard;

import java.util.LinkedList;
import java.util.List;

public class Break {

	private int playerId;
	private int breakId;
	private int score;
	private List<Ball> balls;
	
	public Break(int playerId, int breakId) {
		this.playerId = playerId;
		this.breakId = breakId;
		score = 0;
		balls = new LinkedList<Ball>();
	}
	
	public void pot(Ball ball) {
		this.score += ball.getValue();
		balls.add(ball);
	}
	
	public void undo() {
		if (balls.size() > 0) {
			Ball ball = balls.get(balls.size() - 1);
			score -= ball.getValue();
			balls.remove(balls.size() - 1);
		}
	}

	public int getPlayerId() {
		return playerId;
	}

	public int getBreakId() {
		return breakId;
	}

	public int getScore() {
		return score;
	}

	public List<Ball> getBalls() {
		return balls;
	}
}
